package renderers;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

public class LabelRenderer extends JLabel implements TableCellRenderer {

	private static final long serialVersionUID = 1L;

	private final DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();

	public LabelRenderer() {
	}

	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

		this.renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		setForeground(this.renderer.getForeground());
		setOpaque(true);
		setBorder(this.renderer.getBorder());
		setFont(this.renderer.getFont().deriveFont(Font.BOLD));
		setText(this.renderer.getText());
		setForeground(Color.BLACK);
		setIcon(null);
		if (this.renderer.getText().equals("FUNCTIONALITY"))
			setForeground(Color.BLUE);
		else if (this.renderer.getText().equals("QUALITY"))
			setForeground(Color.RED);
		else if (this.renderer.getText().equals(""))
			setIcon(new ImageIcon(this.getClass().getResource("/delete.png")));

		this.setHorizontalAlignment(JLabel.CENTER);
		this.setVerticalAlignment(JLabel.CENTER);

		return this;
	}

}
